package com.common.api.exception;

import com.common.api.enums.BaseErrorEnum;
import com.common.api.iface.ErrorDescribe;

import lombok.Getter;

/**
 * @author ficus
 * 基础异常定义
 */
@Getter
public class CommonException extends RuntimeException{

	private static final long serialVersionUID = 1L;

	/**异常编码*/
	private String errorCode;
	
	/**异常信息*/
	private String errorMsg;

	/**异常详情 */
	private String errorDetail;
	
	public CommonException(ErrorDescribe errorDescribe) {
		super(errorDescribe.getErrorMsg());
		this.errorCode =errorDescribe.getErrorCode();
		this.errorMsg = errorDescribe.getErrorMsg();
	}

	public CommonException(ErrorDescribe errorDescribe,String errorDetail) {
		super(errorDetail);
		this.errorCode =errorDescribe.getErrorCode();
		this.errorMsg = errorDescribe.getErrorMsg();
		this.errorDetail=errorDetail;
	}
	
	public CommonException(String errorMsg) {
		super(errorMsg);
		this.errorCode = BaseErrorEnum.UNFILED_ERROR.getErrorCode();
		this.errorMsg = errorMsg;
	}

	@Override
	public String toString() {
		return "CommonException [errorCode=" + errorCode + ", errorMsg=" + errorMsg + ", errorDetail=" + errorDetail
				+ "]";
	}
	
}
